import { createI18n } from "vue-i18n";
import { stringToLowerCase } from "@/utils/lib";

// 导入语言包
import zhLocale from "./zh-cn";
import enLocale from "./en";

// 语言配置
const messages = {
  "zh-cn": zhLocale,
  en: enLocale
};
const userLang = localStorage.getItem("language") || stringToLowerCase(navigator.language) || "zh-cn";

// 创建 i18n
const i18n = createI18n({
  legacy: false,
  globalInjection: true,
  locale: userLang,
  messages: messages
});

export default i18n;
